document.addEventListener('DOMContentLoaded', function() {
	// 获取轮播图元素
	let carousel = document.getElementById('adCarousel');
	let carouselInstance = new bootstrap.Carousel(carousel, {
		interval : 3000, // 3秒轮播一次
		wrap : true,
		ride : 'carousel'
	});

	// 鼠标移入暂停轮播
	carousel.addEventListener('mouseenter', function() {
		//            	console.log(1);
		carouselInstance.pause();

		// 添加暂停提示效果
		let pauseIndicator = document.createElement('div');
		pauseIndicator.innerHTML = '<i class="fas fa-pause"></i>';
		pauseIndicator.style.position = 'absolute';
		pauseIndicator.style.top = '20px';
		pauseIndicator.style.right = '20px';
		pauseIndicator.style.backgroundColor = 'rgba(0,0,0,0.6)';
		pauseIndicator.style.color = 'white';
		pauseIndicator.style.padding = '8px 12px';
		pauseIndicator.style.borderRadius = '50%';
		pauseIndicator.style.zIndex = '10';
		pauseIndicator.style.fontSize = '1.2rem';
		pauseIndicator.id = 'pauseIndicator';

		carousel.appendChild(pauseIndicator);
	});

	// 鼠标移出继续轮播
	carousel.addEventListener('mouseleave', function() {
		carouselInstance.cycle();
		//                console.log(2);
		// 移除暂停提示
		let pauseIndicator = document.getElementById('pauseIndicator');
		if (pauseIndicator) {
			pauseIndicator.remove();
		}
	});

});